package targetToOffer.thrDay;

/**
 * @author Godc
 * @description
 */
public class MissingNumber {
}
class MissingNumberSolution {
    /**
     * 也就是找num[i]!=i的临界
     * @param nums
     * @return
     */
    public int missingNumber(int[] nums) {
        int left=0;
        int right=nums.length-1;
        while(left<=right){
            // 计算mid不容易溢出
            int mid=(right-left)/2+left;
            if(nums[mid]==mid){
                left=mid+1;
            }
            else if(nums[mid]!=mid){
                right=mid-1;
            }

        }
        return left;
    }
}